package com.example.rbac.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;

@Configuration
public class MyImportBeanDefinitionRegistrar implements BeanDefinitionRegistryPostProcessor/*implements ImportBeanDefinitionRegistrar*/ {
//    @Override
//    public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry beanDefinitionRegistry) {
//        //扫描注解
//        Map<String, Object> attributes = annotationMetadata.getAnnotationAttributes(ComponentScan.class.getName());
//
//    }


    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry beanDefinitionRegistry) throws BeansException {
        int beanDefinitionCount = beanDefinitionRegistry.getBeanDefinitionCount();
        System.out.println(beanDefinitionCount);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {

    }
}
